package com.example.demo.shengcheng;

public class name生成 {
    public static String numberToChinese(int number) {
        if(number == 0) {
            return "零";
        }

        String[] chineseDigits = new String[]{"", "一", "二", "三", "四", "五", "六", "七", "八", "九"};
        String[] chineseUnits = new String[]{"", "十", "百", "千", "万", "亿"};

        String result = "";
        int unitIndex = 0;

        while(number > 0) {
            int digit = number % 10;
            if(digit > 0) {
                result = chineseDigits[digit] + chineseUnits[unitIndex] + result;
            } else {
                if(!result.startsWith("零")) {
                    result = "零" + result;
                }
            }
            unitIndex++;
            number /= 10;
        }

        if(result.endsWith("零")) {
            result = result.substring(0, result.length() - 1);
        }

        return result;
    }
}
